/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.forms.tdkhoa;

import com.aptech.beans.Users;
import com.aptech.dao.UserManager;
import com.aptech.forms.dqthanh.CustommerList;
import com.aptech.forms.nhanh.DrugList;
import com.aptech.forms.nhanh.SupplierList;
import com.aptech.forms.phthang.OrdersList;
import static com.aptech.forms.tdkhoa.Report.exportReport;
import com.aptech.utility.DBType;
import com.aptech.utility.DBUtil;
import com.aptech.validate.CryptoUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/**
 *
 * @author Duong Quang
 */
public class Main extends javax.swing.JFrame {

    /**
     * Creates new form Main
     */
    private Properties p2;
    private static final String SUPPLIERID_SQL_FILTER
            = "SELECT SupplierTypes.SupplierTypeName, Suppliers.SupplierID,Suppliers.SupplierName,Suppliers.SupplierAddress,Suppliers.SupplierPhone,Suppliers.SupplierEmail"
            + " FROM Suppliers"
            + " INNER JOIN SupplierTypes"
            + " ON Suppliers.SupplierTypeID = SupplierTypes.SupplierTypeID AND Suppliers.SupplierTypeID=";
    private static final String SUPPLIERID_SQL_ALL
            = "SELECT SupplierTypes.SupplierTypeName, Suppliers.SupplierID,Suppliers.SupplierName,Suppliers.SupplierAddress,Suppliers.SupplierPhone,Suppliers.SupplierEmail"
            + " FROM Suppliers"
            + " INNER JOIN SupplierTypes"
            + " ON Suppliers.SupplierTypeID = SupplierTypes.SupplierTypeID";

    public Main() {
        try {
            initComponents();
            // set windows center sreen
            setLocationRelativeTo(null);

            // search current user
            final String KEY_FILE = "E:/howto.key";
            final String PWD_FILE = "E:/howto.properties";

            File file = new File(KEY_FILE);
            FileReader fileReader = new FileReader(PWD_FILE);

            if (file.exists() && fileReader.read() > 0) {
                p2 = new Properties();
                p2.load(fileReader);
                String encryptedPwd = p2.getProperty("Password");

                jmMainUser.setText("> Hello, " + p2.getProperty("UserName"));
                CryptoUtils.decrypt(encryptedPwd, file);
            } else {
                this.dispose();
            }
            Connection conn = DBUtil.getConnection(DBType.myConnection);
            if (conn != null) {
                Users user = new Users();
                user = UserManager.checkUserInRole(p2.getProperty("UserName"));
                setRole(user.getRoleID());
            } else {
                this.dispose();
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (GeneralSecurityException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void setRole(int RoleID) {
        //                user = UserManager.checkUserInRole("user06");
        switch (RoleID) {

            // User is Administrator
            case 1:
                jButtonCustomer.setVisible(false);
                jmiMainCustomer.setVisible(false);

                jButtonDrug.setVisible(false);
                jmiMainDrug.setVisible(false);

                jButtonOrder.setVisible(false);
                jmiMainOrder.setVisible(false);

                jButtonReport.setVisible(false);
                jmMainReport.setVisible(false);

                jButtonSaleInvoice.setVisible(false);
                jmiMainSaleInvoice.setVisible(false);

                jButtonSupplier.setVisible(false);
                jmiMainSupplier.setVisible(false);

                jButtonUser.setVisible(true);
                jmiMainAccount.setVisible(true);

                jButtonResetPassword.setVisible(true);
                jmiMainResetPassword.setVisible(true);
                break;
            // User is Accountant
            case 2:
                jButtonCustomer.setVisible(false);
                jmiMainCustomer.setVisible(false);

                jButtonDrug.setVisible(false);
                jmiMainDrug.setVisible(false);

                jButtonOrder.setVisible(false);
                jmiMainOrder.setVisible(false);

                jButtonReport.setVisible(true);
                jmMainReport.setVisible(true);

                jButtonSaleInvoice.setVisible(true);
                jmiMainSaleInvoice.setVisible(true);

                jButtonSupplier.setVisible(false);
                jmiMainSupplier.setVisible(false);

                jButtonUser.setVisible(false);
                jmiMainAccount.setVisible(false);

                jButtonResetPassword.setVisible(false);
                jmiMainResetPassword.setVisible(false);
                break;
            // User is Seller
            case 3:
                jButtonCustomer.setVisible(true);
                jmiMainCustomer.setVisible(true);

                jButtonDrug.setVisible(true);
                jmiMainDrug.setVisible(true);

                jButtonOrder.setVisible(true);
                jmiMainOrder.setVisible(true);

                jButtonReport.setVisible(true);
                jmMainReport.setVisible(true);

                jButtonSaleInvoice.setVisible(false);
                jmiMainSaleInvoice.setVisible(false);

                jButtonSupplier.setVisible(true);
                jmiMainSupplier.setVisible(true);

                jButtonUser.setVisible(false);
                jmiMainAccount.setVisible(false);

                jButtonResetPassword.setVisible(false);
                jmiMainResetPassword.setVisible(false);
                break;
            default:
                this.dispose();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jButtonUser = new javax.swing.JButton();
        jButtonCustomer = new javax.swing.JButton();
        jButtonDrug = new javax.swing.JButton();
        jButtonSupplier = new javax.swing.JButton();
        jButtonOrder = new javax.swing.JButton();
        jButtonSaleInvoice = new javax.swing.JButton();
        jButtonReport = new javax.swing.JButton();
        jButtonResetPassword = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jmMainFile = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jmMainManager = new javax.swing.JMenu();
        jmiMainAccount = new javax.swing.JMenuItem();
        jmiMainCustomer = new javax.swing.JMenuItem();
        jmiMainDrug = new javax.swing.JMenuItem();
        jmiMainSupplier = new javax.swing.JMenuItem();
        jmiMainOrder = new javax.swing.JMenuItem();
        jmiMainSaleInvoice = new javax.swing.JMenuItem();
        jmiMainResetPassword = new javax.swing.JMenuItem();
        jmMainReport = new javax.swing.JMenu();
        jmiMainCustomer3 = new javax.swing.JMenuItem();
        jmiMainDrug1 = new javax.swing.JMenuItem();
        jmiMainSupplier1 = new javax.swing.JMenuItem();
        jmiMainOrder1 = new javax.swing.JMenuItem();
        jmiMainSaleInvoice1 = new javax.swing.JMenuItem();
        jmMainSpacing = new javax.swing.JMenu();
        jmMainUser = new javax.swing.JMenu();
        jmiMainProfile = new javax.swing.JMenuItem();
        jmiMainSignout = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Medical Store Billing");
        setIconImage(new ImageIcon(getClass().getResource("/com/image/icon.png")).getImage());
        setName("frameMain"); // NOI18N
        setResizable(false);

        jPanel1.setPreferredSize(new java.awt.Dimension(480, 480));
        jPanel1.setLayout(new java.awt.GridLayout(3, 3, 20, 20));

        jButtonUser.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jButtonUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/034.png"))); // NOI18N
        jButtonUser.setText("<html>User <br />Managerment</html>");
        jButtonUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonUserActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonUser);

        jButtonCustomer.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jButtonCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/035.png"))); // NOI18N
        jButtonCustomer.setText("<html>Customer<br />Management</html>");
        jButtonCustomer.setToolTipText("");
        jButtonCustomer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCustomerActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonCustomer);

        jButtonDrug.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jButtonDrug.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/036.png"))); // NOI18N
        jButtonDrug.setText("<html>Drug<br />Management</html>");
        jButtonDrug.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDrugActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonDrug);

        jButtonSupplier.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jButtonSupplier.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/037.png"))); // NOI18N
        jButtonSupplier.setText("<html>Supplier<br />Management</html>");
        jButtonSupplier.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSupplierActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonSupplier);

        jButtonOrder.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jButtonOrder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/038.png"))); // NOI18N
        jButtonOrder.setText("<html>Order<br />Management</html>");
        jButtonOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOrderActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonOrder);

        jButtonSaleInvoice.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jButtonSaleInvoice.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/039.png"))); // NOI18N
        jButtonSaleInvoice.setText("<html>Sale<br />Invoice</html>");
        jButtonSaleInvoice.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaleInvoiceActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonSaleInvoice);

        jButtonReport.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jButtonReport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/040.png"))); // NOI18N
        jButtonReport.setText("Report");
        jButtonReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonReportActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonReport);

        jButtonResetPassword.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jButtonResetPassword.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/055.png"))); // NOI18N
        jButtonResetPassword.setText("<html>Reset<br />Password</html>");
        jButtonResetPassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonResetPasswordActionPerformed(evt);
            }
        });
        jPanel1.add(jButtonResetPassword);

        jmMainFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/017.png"))); // NOI18N
        jmMainFile.setText("File");
        jmMainFile.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/014.png"))); // NOI18N
        jMenuItem1.setText("Exit");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jmMainFile.add(jMenuItem1);

        jMenuBar1.add(jmMainFile);

        jmMainManager.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/018.png"))); // NOI18N
        jmMainManager.setText("Manager");
        jmMainManager.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N

        jmiMainAccount.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        jmiMainAccount.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainAccount.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/043.png"))); // NOI18N
        jmiMainAccount.setText("Account");
        jmiMainAccount.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainAccountActionPerformed(evt);
            }
        });
        jmMainManager.add(jmiMainAccount);

        jmiMainCustomer.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK));
        jmiMainCustomer.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/044.png"))); // NOI18N
        jmiMainCustomer.setText("Customer");
        jmiMainCustomer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainCustomerActionPerformed(evt);
            }
        });
        jmMainManager.add(jmiMainCustomer);

        jmiMainDrug.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
        jmiMainDrug.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainDrug.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/045.png"))); // NOI18N
        jmiMainDrug.setText("Drug");
        jmiMainDrug.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainDrugActionPerformed(evt);
            }
        });
        jmMainManager.add(jmiMainDrug);

        jmiMainSupplier.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        jmiMainSupplier.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainSupplier.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/046.png"))); // NOI18N
        jmiMainSupplier.setText("Supplier");
        jmiMainSupplier.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainSupplierActionPerformed(evt);
            }
        });
        jmMainManager.add(jmiMainSupplier);

        jmiMainOrder.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        jmiMainOrder.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainOrder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/047.png"))); // NOI18N
        jmiMainOrder.setText("Order");
        jmiMainOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainOrderActionPerformed(evt);
            }
        });
        jmMainManager.add(jmiMainOrder);

        jmiMainSaleInvoice.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.CTRL_MASK));
        jmiMainSaleInvoice.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainSaleInvoice.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/048.png"))); // NOI18N
        jmiMainSaleInvoice.setText("Salve Invoice");
        jmiMainSaleInvoice.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainSaleInvoiceActionPerformed(evt);
            }
        });
        jmMainManager.add(jmiMainSaleInvoice);

        jmiMainResetPassword.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK));
        jmiMainResetPassword.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainResetPassword.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/056.png"))); // NOI18N
        jmiMainResetPassword.setText("ResetPassword");
        jmiMainResetPassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainResetPasswordActionPerformed(evt);
            }
        });
        jmMainManager.add(jmiMainResetPassword);

        jMenuBar1.add(jmMainManager);

        jmMainReport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/041.png"))); // NOI18N
        jmMainReport.setText("Report");
        jmMainReport.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N

        jmiMainCustomer3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.SHIFT_MASK));
        jmiMainCustomer3.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainCustomer3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/044.png"))); // NOI18N
        jmiMainCustomer3.setText("Customer");
        jmiMainCustomer3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainCustomer3ActionPerformed(evt);
            }
        });
        jmMainReport.add(jmiMainCustomer3);

        jmiMainDrug1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.SHIFT_MASK));
        jmiMainDrug1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainDrug1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/045.png"))); // NOI18N
        jmiMainDrug1.setText("Drug");
        jmiMainDrug1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainDrug1ActionPerformed(evt);
            }
        });
        jmMainReport.add(jmiMainDrug1);

        jmiMainSupplier1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.SHIFT_MASK));
        jmiMainSupplier1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainSupplier1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/046.png"))); // NOI18N
        jmiMainSupplier1.setText("All Supplier");
        jmiMainSupplier1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainSupplier1ActionPerformed(evt);
            }
        });
        jmMainReport.add(jmiMainSupplier1);

        jmiMainOrder1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK));
        jmiMainOrder1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainOrder1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/047.png"))); // NOI18N
        jmiMainOrder1.setText("Order");
        jmiMainOrder1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainOrder1ActionPerformed(evt);
            }
        });
        jmMainReport.add(jmiMainOrder1);

        jmiMainSaleInvoice1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.SHIFT_MASK));
        jmiMainSaleInvoice1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainSaleInvoice1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/048.png"))); // NOI18N
        jmiMainSaleInvoice1.setText("Salve Invoice");
        jmiMainSaleInvoice1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainSaleInvoice1ActionPerformed(evt);
            }
        });
        jmMainReport.add(jmiMainSaleInvoice1);

        jMenuBar1.add(jmMainReport);

        jmMainSpacing.setBorderPainted(true);
        jmMainSpacing.setContentAreaFilled(false);
        jmMainSpacing.setEnabled(false);
        jmMainSpacing.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
        jmMainSpacing.setMargin(new java.awt.Insets(0, 150, 0, 0));
        jMenuBar1.add(jmMainSpacing);

        jmMainUser.setForeground(new java.awt.Color(102, 102, 102));
        jmMainUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/049.png"))); // NOI18N
        jmMainUser.setText(">");
        jmMainUser.setBorderPainted(true);
        jmMainUser.setContentAreaFilled(false);
        jmMainUser.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
        jmMainUser.setMargin(new java.awt.Insets(0, 0, 0, 20));

        jmiMainProfile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jmiMainProfile.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainProfile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/020.png"))); // NOI18N
        jmiMainProfile.setText("Change Password");
        jmiMainProfile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainProfileActionPerformed(evt);
            }
        });
        jmMainUser.add(jmiMainProfile);

        jmiMainSignout.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jmiMainSignout.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiMainSignout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/image/021.png"))); // NOI18N
        jmiMainSignout.setText("Signout");
        jmiMainSignout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiMainSignoutActionPerformed(evt);
            }
        });
        jmMainUser.add(jmiMainSignout);

        jMenuBar1.add(jmMainUser);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonUserActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonUserActionPerformed
    {//GEN-HEADEREND:event_jButtonUserActionPerformed
        new AccountList().setVisible(true);
    }//GEN-LAST:event_jButtonUserActionPerformed

    private void jButtonCustomerActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonCustomerActionPerformed
    {//GEN-HEADEREND:event_jButtonCustomerActionPerformed
        // TODO add your handling code here:
        new CustommerList().setVisible(true);
    }//GEN-LAST:event_jButtonCustomerActionPerformed

    private void jButtonDrugActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonDrugActionPerformed
    {//GEN-HEADEREND:event_jButtonDrugActionPerformed
        // TODO add your handling code here:
        new DrugList().setVisible(true);
    }//GEN-LAST:event_jButtonDrugActionPerformed

    private void jButtonSupplierActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonSupplierActionPerformed
    {//GEN-HEADEREND:event_jButtonSupplierActionPerformed
        try {
            new SupplierList().setVisible(true);
        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jButtonSupplierActionPerformed

    private void jButtonOrderActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonOrderActionPerformed
    {//GEN-HEADEREND:event_jButtonOrderActionPerformed
        new OrdersList().setVisible(true);
    }//GEN-LAST:event_jButtonOrderActionPerformed

    private void jButtonSaleInvoiceActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonSaleInvoiceActionPerformed
    {//GEN-HEADEREND:event_jButtonSaleInvoiceActionPerformed
        new SaleInvoiceList().setVisible(true);

    }//GEN-LAST:event_jButtonSaleInvoiceActionPerformed

    private void jButtonReportActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonReportActionPerformed
    {//GEN-HEADEREND:event_jButtonReportActionPerformed
        new Report().setVisible(true);
    }//GEN-LAST:event_jButtonReportActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuItem1ActionPerformed
    {//GEN-HEADEREND:event_jMenuItem1ActionPerformed
        this.dispose();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jmiMainAccountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainAccountActionPerformed
        new AccountList().setVisible(true);
    }//GEN-LAST:event_jmiMainAccountActionPerformed

    private void jmiMainCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainCustomerActionPerformed
        new CustommerList().setVisible(true);
    }//GEN-LAST:event_jmiMainCustomerActionPerformed

    private void jmiMainDrugActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainDrugActionPerformed
        // TODO add your handling code here:
        new DrugList().setVisible(true);
    }//GEN-LAST:event_jmiMainDrugActionPerformed

    private void jmiMainSupplierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainSupplierActionPerformed
        try {
            new SupplierList().setVisible(true);
        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jmiMainSupplierActionPerformed

    private void jmiMainOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainOrderActionPerformed
        new OrdersList().setVisible(true);
    }//GEN-LAST:event_jmiMainOrderActionPerformed

    private void jmiMainSaleInvoiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainSaleInvoiceActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jmiMainSaleInvoiceActionPerformed

    private void jmiMainProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainProfileActionPerformed
        // TODO add your handling code here:
        new ChangePassword().setVisible(true);
    }//GEN-LAST:event_jmiMainProfileActionPerformed

    private void jmiMainSignoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainSignoutActionPerformed
        this.dispose();
        new Login().setVisible(true);

        File keyFile = new File("D:/howto.key");
        File passwordFile = new File("D:/howto.properties");

        if (keyFile.exists() && passwordFile.exists()) {
            keyFile.delete();
            passwordFile.delete();

        }

    }//GEN-LAST:event_jmiMainSignoutActionPerformed

    private void jButtonResetPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonResetPasswordActionPerformed
        // TODO add your handling code here:
        new ResetPassword().setVisible(true);
    }//GEN-LAST:event_jButtonResetPasswordActionPerformed

    private void jmiMainResetPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainResetPasswordActionPerformed
        // TODO add your handling code here:
        new ResetPassword().setVisible(true);

    }//GEN-LAST:event_jmiMainResetPasswordActionPerformed

    private void jmiMainCustomer3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainCustomer3ActionPerformed
// Export Customer report
        InputStream is = getClass().getResourceAsStream("/report/customerReport.jrxml");
        if (is != null) {
            exportReport(is);
        } else {
            JOptionPane.showMessageDialog(null, "Cannot find report!\nPlease, contact your administrator", "Message", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jmiMainCustomer3ActionPerformed

    private void jmiMainDrug1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainDrug1ActionPerformed
        // Export Drug report
        InputStream is = getClass().getResourceAsStream("/report/drugReport.jrxml");
        if (is != null) {
            exportReport(is);
        } else {
            JOptionPane.showMessageDialog(null, "Cannot find report!\nPlease, contact your administrator", "Message", JOptionPane.ERROR_MESSAGE);

        }
    }//GEN-LAST:event_jmiMainDrug1ActionPerformed

    private void jmiMainSupplier1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainSupplier1ActionPerformed
        InputStream is = getClass().getResourceAsStream("/report/supplierReport.jrxml");
        if (is != null) {
            exportReport(is, SUPPLIERID_SQL_ALL);
        } else {
            JOptionPane.showMessageDialog(null, "Cannot find report!\nPlease, contact your administrator", "Message", JOptionPane.ERROR_MESSAGE);

        }
    }//GEN-LAST:event_jmiMainSupplier1ActionPerformed

    private void jmiMainOrder1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainOrder1ActionPerformed
        new Report().setVisible(true);

    }//GEN-LAST:event_jmiMainOrder1ActionPerformed

    private void jmiMainSaleInvoice1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMainSaleInvoice1ActionPerformed
        new Report().setVisible(true);
    }//GEN-LAST:event_jmiMainSaleInvoice1ActionPerformed

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AccountList.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AccountList.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AccountList.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AccountList.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });

    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCustomer;
    private javax.swing.JButton jButtonDrug;
    private javax.swing.JButton jButtonOrder;
    private javax.swing.JButton jButtonReport;
    private javax.swing.JButton jButtonResetPassword;
    private javax.swing.JButton jButtonSaleInvoice;
    private javax.swing.JButton jButtonSupplier;
    private javax.swing.JButton jButtonUser;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JMenu jmMainFile;
    private javax.swing.JMenu jmMainManager;
    private javax.swing.JMenu jmMainReport;
    private javax.swing.JMenu jmMainSpacing;
    private javax.swing.JMenu jmMainUser;
    private javax.swing.JMenuItem jmiMainAccount;
    private javax.swing.JMenuItem jmiMainCustomer;
    private javax.swing.JMenuItem jmiMainCustomer3;
    private javax.swing.JMenuItem jmiMainDrug;
    private javax.swing.JMenuItem jmiMainDrug1;
    private javax.swing.JMenuItem jmiMainOrder;
    private javax.swing.JMenuItem jmiMainOrder1;
    private javax.swing.JMenuItem jmiMainProfile;
    private javax.swing.JMenuItem jmiMainResetPassword;
    private javax.swing.JMenuItem jmiMainSaleInvoice;
    private javax.swing.JMenuItem jmiMainSaleInvoice1;
    private javax.swing.JMenuItem jmiMainSignout;
    private javax.swing.JMenuItem jmiMainSupplier;
    private javax.swing.JMenuItem jmiMainSupplier1;
    // End of variables declaration//GEN-END:variables
}
